package com.bw.controller;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @Author: Yanyanyu
 * @Date: 2024/3/11 8:51
 */
@RestController
public class ProducerController {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("send/{msg}")
   /* @Scheduled(cron = "0 0/1 * * * ?")*/
    public String send(@PathVariable String msg){

        Random random = new Random();
        Integer num=random.nextInt(120-30+1)+30;
        System.out.println(num);
        for (Integer i = 0; i < num; i++) {
            rocketMQTemplate.convertAndSend("demo1",msg);
        }
        return "success";
    }

}
